From 4804e252d1612224a66e674e22e7cab00d8e8543 Mon Sep 17 00:00:00 2001 From: robertl Date: Sat, 8 Mar 2003 03:43:55 +0000 Subject: [PATCH] Allow escaping of comment char. --- mkstyle.sh | 2 +- xcsv.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/mkstyle.sh b/mkstyle.sh index db643ca7e..cf5650bce 100755 --- a/mkstyle.sh +++ b/mkstyle.sh @@ -5,7 +5,7 @@ do [ $A = "README" ] && continue ALIST="{ \"$A\", $A } , $ALIST" echo "static char $A[] = " - sed 's/"/\\"/g;s/\(^.\)/"\1/g;s/\(.$\)/\1\\\n"/g' $i + sed 's/\\/\\\\/;s/"/\\"/g;s/\(^.\)/"\1/g;s/\(.$\)/\1\\\n"/g' $i echo ";" done diff --git a/xcsv.c b/xcsv.c index 928122399..24f7df3fc 100644 --- a/xcsv.c +++ b/xcsv.c @@ -173,8 +173,14 @@ xcsv_parse_style_line(const char *sbuff) */ /* whack off any comments */ - if ((p = strchr(sbuff, '#')) != NULL) - *p = '\0'; + if ((p = strchr(sbuff, '#')) != NULL) { + if ((p > sbuff) && p[-1] == '\\') { + memmove(p-1, p, strlen(p)); + p[strlen(p)-1] = '\0'; + } else { + *p = '\0'; + } + } if (strlen(sbuff)) { if (ISSTOKEN(sbuff, "FIELD_DELIMITER")) { -- 2.30.2